package org.wattdepot.cli.command;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the FuelTypeCommand class.
 * 
 * @author Yichi Xu
 *
 */
public class TestFuelTypeCommand extends CommandTestBed {

  @Test
  @Override
  public void testDoCommand() {
    String command;
    String result;
    
    FuelTypeCommand fuelTypeCommand = new FuelTypeCommand(this.client);
    
    //Sad tests
    //Correct input "fueltypes SIM_KAHE"
    command = "fueltypes foo";
    result = fuelTypeCommand.doCommand(command);
    assertTrue("Checking that the source is invalid.", 
        result.startsWith(WattDepotCliCommand.SOURCE_ERROR));
    
    //Happy tests
    command = "fueltypes SIM_KAHE";
    result = fuelTypeCommand.doCommand(command);
    assertTrue("Checking that there is a result for the query",
        result.contains("Type"));
    assertFalse("Checking that the command is valid.",
        result.equals(WattDepotCliCommand.reportUnknownCommand(command)));
    assertFalse("Checking that the connection is fine.",
        result.equals(WattDepotCliCommand.CONNECTION_ERROR));
    assertFalse("Checking that the source is valid.",
        result.startsWith(WattDepotCliCommand.SOURCE_ERROR));
  }
}
